<template>
  <button @click="isShow=true">展示广告</button>
 <teleport to='body'>
   <div class="test" v-show="isShow">
    <h2>我是弹窗广告</h2>
    <button @click="isShow=false">关闭弹窗</button>
</div>
 </teleport>
</template>

<script lang='ts' setup name='Modal'>
import {ref} from "vue"
let isShow=ref(false)
</script>

<style scoped>
.test{
  width: 200px; 
  height: 200px;
  background-color: pink;
  border-radius: 10px;
  text-align: center;
  position: fixed;
  left:50%;
  top: 50px;
  margin-left: -100px;
}
</style>